package com.evaluation.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.evaluation.entity.DeptEvaluatingRelation;
import com.evaluation.mapper.DeptEvaluatingRelationMapper;
import com.evaluation.service.DeptEvaluatingRelationService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 部门测评关系服务实现类
 */
@Service
public class DeptEvaluatingRelationServiceImpl extends ServiceImpl<DeptEvaluatingRelationMapper, DeptEvaluatingRelation> implements DeptEvaluatingRelationService {

    @Override
    public List<DeptEvaluatingRelation> getPendingByTeacher(String jsxm) {
        QueryWrapper<DeptEvaluatingRelation> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("cpjs", jsxm)  // 使用Java属性名而不是数据库字段名
                .eq("cpbs", "0") // 未测评
                .orderByAsc("bcpbm");
        return this.list(queryWrapper);
    }

    @Override
    public List<DeptEvaluatingRelation> getEvaluatedByTeacher(String jsxm) {
        QueryWrapper<DeptEvaluatingRelation> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("cpjs", jsxm)  // 使用Java属性名而不是数据库字段名
                .eq("cpbs", "1") // 已测评
                .orderByDesc("cpsj");
        return this.list(queryWrapper);
    }

    @Override
    public List<Map<String, Object>> getPendingByTeacherWithIndicatorName(String jsxm) {
        return this.baseMapper.getPendingByTeacherWithIndicatorName(jsxm);
    }

    @Override
    public List<Map<String, Object>> getEvaluatedByTeacherWithIndicatorName(String jsxm) {
        return this.baseMapper.getEvaluatedByTeacherWithIndicatorName(jsxm);
    }
}
